home *** CD-ROM | disk | FTP | other *** search
/ Champak 26 (Anniversary Edition) / Volume 26 [Anniversary Edition] - JOGO DISK .iso / Fight / starwars.swf / scripts / frame_145 / PlaceObject2_150_232 / CLIPACTIONRECORD onClipEvent(load).as < prev   
Text File  |  2006-09-05  |  4KB  |  156 lines

  1. onClipEvent(load){
  2.    function stateCheck()
  3.    {
  4.       if(attackFlag == 0)
  5.       {
  6.          if(beforeState != 2 and nowState == 2)
  7.          {
  8.             this.gotoAndStop("standing");
  9.             this._xscale = math.abs(this._xscale);
  10.             this.standUp.goToAndStop("walking");
  11.          }
  12.          else if(beforeState != 4 and nowState == 4)
  13.          {
  14.             this.gotoAndStop("standing");
  15.             this._xscale = - math.abs(this._xscale);
  16.             this.standUp.goToAndStop("walkimg");
  17.          }
  18.          else if(beforeState != 3 and nowState == 3)
  19.          {
  20.             this.gotoAndStop("sitdown");
  21.             this.sitDown.goToAndStop("down");
  22.          }
  23.       }
  24.    }
  25.    function keyInMove()
  26.    {
  27.       if(attackFlag == 0)
  28.       {
  29.          if(key.isDown(key.RIGHT) and this._x < 500)
  30.          {
  31.             nowState = 2;
  32.             stateCheck();
  33.             beforeState = 2;
  34.             this._x += speed;
  35.             this.standUp.play();
  36.          }
  37.          else if(key.isDown(key.LEFT) and 0 < this._x)
  38.          {
  39.             nowState = 4;
  40.             stateCheck();
  41.             beforeState = 4;
  42.             this._x -= speed;
  43.             this.standUp.play();
  44.          }
  45.          else if(key.isDown(key.DOWN))
  46.          {
  47.             nowState = 3;
  48.             stateCheck();
  49.             beforeState = 3;
  50.          }
  51.       }
  52.    }
  53.    function AttackCheck()
  54.    {
  55.       if(attackFlag == 0)
  56.       {
  57.          if(attackNumber == 1)
  58.          {
  59.             if(nowState == 4 or nowState == 2)
  60.             {
  61.                attackFlag = 1;
  62.                attackNumber = 0;
  63.                this.standUp.goToAndPlay("fist");
  64.             }
  65.             else if(nowState == 3)
  66.             {
  67.                attackFlag = 1;
  68.                attackNumber = 0;
  69.                this.sitDown.gotoAndPlay("downfist");
  70.             }
  71.          }
  72.          else if(attackNumber == 2)
  73.          {
  74.             if(nowState == 4 or nowState == 2)
  75.             {
  76.                attackFlag = 1;
  77.                attackNumber = 0;
  78.                this.standUp.goToAndPlay("kick");
  79.             }
  80.             else if(nowState == 3)
  81.             {
  82.                attackFlag = 1;
  83.                attackNumber = 0;
  84.                this.sitDown.gotoAndPlay("downkick");
  85.             }
  86.          }
  87.       }
  88.    }
  89.    function KeyInAttack()
  90.    {
  91.       if(attackFlag == 0)
  92.       {
  93.          if(Key.isDown(90))
  94.          {
  95.             attackNumber = 1;
  96.             AttackCheck();
  97.             this.mySound("attackSound1");
  98.          }
  99.          if(Key.isDown(88))
  100.          {
  101.             attackNumber = 2;
  102.             AttackCheck();
  103.             this.mySound("attackSound2");
  104.          }
  105.       }
  106.    }
  107.    function chMainStroke(numK)
  108.    {
  109.       if(0 < energy)
  110.       {
  111.          attackFlag = 1;
  112.          energy -= 10;
  113.          _root.energyLine.energySub(10);
  114.          if(numK == 1)
  115.          {
  116.             if(0 < energy)
  117.             {
  118.                this.mySound("Chmainhit");
  119.                this.standUp.gotoAndPlay("hit");
  120.             }
  121.             else
  122.             {
  123.                this.mySound("chManDie");
  124.                this.standUp.gotoAndPlay("die");
  125.             }
  126.          }
  127.          else if(numK == 2)
  128.          {
  129.             if(0 < energy)
  130.             {
  131.                this.mySound("Chmainhit");
  132.                this.sitDown.gotoAndPlay("downhit");
  133.             }
  134.             else
  135.             {
  136.                this.mySound("chManDie");
  137.                this.sitDown.gotoAndPlay("downdie");
  138.             }
  139.          }
  140.       }
  141.    }
  142.    function mySound(soundName)
  143.    {
  144.       GSound.stop();
  145.       GSound.attachSound(soundName);
  146.       GSound.start();
  147.    }
  148.    speed = 4;
  149.    beforeState = 0;
  150.    nowState = 0;
  151.    attackFlag = 0;
  152.    attackNumber = 0;
  153.    energy = 200;
  154.    GSound = new Sound(this);
  155. }
  156.